package org.apache.james.hibernate.entity;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;

@Entity
@IdClass(MailHeader.MailHeaderPk.class)
public class MailHeader {

	Integer mailId;
	int lineNo;
	String name;
	String value;
	
	@Id
	public Integer getMailId() {
		return mailId;
	}
	
	@Id
	public int getLineNo() {
		return lineNo;
	}
	
	public void setMailId(Integer mailId) {
		this.mailId = mailId;
	}

	public void setLineNo(int lineNo) {
		this.lineNo = lineNo;
	}
	

	public String getName() {
		return name;
	}

	public void setName(String key) {
		this.name = key;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	
	static class MailHeaderPk implements Serializable {
		/**
		 * 
		 */
		private static final long serialVersionUID = -4597666401490372554L;

		Integer mailId;
		int lineNo;

		
		
		public Integer getMailId() {
			return mailId;
		}

		public void setMailId(Integer mailId) {
			this.mailId = mailId;
		}

		public int getLineNo() {
			return lineNo;
		}

		public void setLineNo(int lineNo) {
			this.lineNo = lineNo;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj instanceof MailHeaderPk) {
				MailHeaderPk m = (MailHeaderPk)obj;
				return m.mailId.equals(mailId) && m.lineNo == lineNo; 
			}
			return false;
		}
		
		@Override
		public int hashCode() {
			return (mailId << 8) ^ lineNo;
		}
		
	}


}
